4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 namespace Microsoft
.JScript
{
19 using System
.Reflection
;
20 using System
.Globalization
;
22 internal class JSClosureProperty
: JSWrappedProperty
{
23 private MethodInfo getMeth
;
24 private MethodInfo setMeth
;
26 internal JSClosureProperty(PropertyInfo property
, MethodInfo getMeth
, MethodInfo setMeth
)
27 :base(property
, null){
28 this.getMeth
= getMeth
;
29 this.setMeth
= setMeth
;
32 public override Object
GetValue(Object obj
, BindingFlags invokeAttr
, Binder binder
, Object
[] index
, CultureInfo culture
) {
33 if (this.getMeth
== null)
34 throw new MissingMethodException();
35 return this.getMeth
.Invoke(obj
, invokeAttr
, binder
, index
, culture
);
38 public override MethodInfo
GetGetMethod(bool nonPublic
){
39 if (nonPublic
|| (this.getMeth
!= null && this.getMeth
.IsPublic
))
45 public override MethodInfo
GetSetMethod(bool nonPublic
){
46 if (nonPublic
|| (this.setMeth
!= null && this.setMeth
.IsPublic
))
52 public override void SetValue(Object obj
, Object
value, BindingFlags invokeAttr
, Binder binder
, Object
[] index
, CultureInfo culture
) {
53 if (this.setMeth
== null)
54 throw new MissingMethodException();
55 int n
= index
== null ? 0 : index
.Length
;
56 Object
[] pars
= new Object
[n
+1];
59 ArrayObject
.Copy(index
, 0, pars
, 1, n
);
60 this.setMeth
.Invoke(obj
, invokeAttr
, binder
, pars
, culture
);